package com.ssy.lingxi.member.merchant.entity;

import com.ssy.lingxi.member.merchant.handler.annotation.PaymentTypeAnnotation;
import com.ssy.lingxi.member.merchant.handler.annotation.SettlementDocumentsAnnotation;
import com.ssy.lingxi.member.merchant.handler.converter.JpaJsonToBusinessCategoryConverter;
import com.ssy.lingxi.member.merchant.model.bo.BusinessCategoryBO;
import lombok.Data;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;

/**
 * 会员主营品类
 * @author 万宁
 * @version 2.0.0
 * @date 2021-05-25
 */
@Data
@Entity
@Table(schema = "public", name = "ms_mc_member_business_category")
public class MemberBusinessCategoryDO implements Serializable {
    private static final long serialVersionUID = 3908647347241754608L;

    /**
     * 主键id
     */
    @Id
    @GeneratedValue(strategy= GenerationType.SEQUENCE, generator="member_business_category_seq")
    @SequenceGenerator(sequenceName="ms_mc_member_business_category_seq", name="member_business_category_seq", allocationSize = 1)
    private Long id;

    /**
     * 品类列表
     */
    @Column(columnDefinition = "jsonb")
    @Convert(converter = JpaJsonToBusinessCategoryConverter.class)
    private List<BusinessCategoryBO> categories;

    /**
     * 结算方式，定义在 PurchaseContractPayTypeEnum 中
     */
    @Column
    private Integer payType;

    /**
     * 付款周期（月）
     */
    @Column
    private Integer month;

    /**
     * 付款周期（每月X日）
     */
    @Column
    private Integer monthDay;

    /**
     * 付款周期（天）
     */
    @Column
    private Integer days;

    /**
     * 发票类型枚举，定义在 BusinessCategoryInvoiceTypeEnum 中
     */
    @Column
    private Integer invoiceType;

    /**
     * 发票类型名称
     */
    @Column(columnDefinition = "varchar(50)")
    private String invoiceTypeName;

    /**
     * 税点
     */
    @Column(columnDefinition = "numeric")
    private BigDecimal taxPoint;

    /**
     * 预付款：1:不需预付 2：需要预付
     */
    @Column
    private Integer advanceCharge;

    /**
     * 结算单据枚举，定义在 SettlementDocumentsEnum 中
     */
    @Column
    private Integer settlementDocuments;

    /**
     * 付款方式枚举，定义在 PaymentTypeEnum 中
     */
    @Column
    private Integer paymentType;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public List<BusinessCategoryBO> getCategories() {
        return categories;
    }

    public void setCategories(List<BusinessCategoryBO> categories) {
        this.categories = categories;
    }

    public Integer getPayType() {
        return payType;
    }

    public void setPayType(Integer payType) {
        this.payType = payType;
    }

    public Integer getMonth() {
        return month;
    }

    public void setMonth(Integer month) {
        this.month = month;
    }

    public Integer getMonthDay() {
        return monthDay;
    }

    public void setMonthDay(Integer monthDay) {
        this.monthDay = monthDay;
    }

    public Integer getDays() {
        return days;
    }

    public void setDays(Integer days) {
        this.days = days;
    }

    public Integer getInvoiceType() {
        return invoiceType;
    }

    public void setInvoiceType(Integer invoiceType) {
        this.invoiceType = invoiceType;
    }

    public String getInvoiceTypeName() {
        return invoiceTypeName;
    }

    public void setInvoiceTypeName(String invoiceTypeName) {
        this.invoiceTypeName = invoiceTypeName;
    }

    public BigDecimal getTaxPoint() {
        return taxPoint;
    }

    public void setTaxPoint(BigDecimal taxPoint) {
        this.taxPoint = taxPoint;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        MemberBusinessCategoryDO that = (MemberBusinessCategoryDO) o;
        return id.equals(that.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
}
